package giaodien;

import java.awt.BorderLayout;
import java.awt.Toolkit;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JToolBar;

import component.MyMenuBar;
import component.MyStatusBar;
import component.MyToolBar;

import event.MyButtonEvent;
import event.MyWindownEvent;

public class FormChinh extends JFrame {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	MyWindownEvent event;
	MyButtonEvent btnevent;
	public MyMenuBar menubar;
	MyToolBar toolbar;
	MyToolBar toolbar1;
	MyStatusBar status;
	public DangNhap dangnhap;
	public TableHangHoa hanghoa;
	public FormChinh() {
		dangnhap=new DangNhap();
		hanghoa=new TableHangHoa();
		event=new MyWindownEvent(this);
		menubar=new MyMenuBar();
		toolbar=new MyToolBar();
		toolbar1=new MyToolBar();
		toolbar1.remove(toolbar1.com);
		toolbar.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
		toolbar1.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
		toolbar1.setOrientation(JToolBar.VERTICAL);
		status=new MyStatusBar();
		btnevent=new MyButtonEvent(this);
		
		setTitle("Chương Trình Quản Lý Vật Tư");
		setIconImage(Toolkit.getDefaultToolkit().getImage("image/Apps-krfb-icon.png"));
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setExtendedState(JFrame.MAXIMIZED_BOTH);
		pack();
		//this.setVisible(true);
		hanghoa.setVisible(true);
		setResizable(false);
		listener();
		setJMenuBar(menubar);
		add(toolbar,BorderLayout.NORTH);
		add(toolbar1,BorderLayout.WEST);
		add(status,BorderLayout.SOUTH);
	}
	public void listener(){
		this.addWindowListener(event);
		hanghoa.addWindowListener(event);
		menubar.btndangnhap.addActionListener((ActionListener)btnevent);
		dangnhap.option.addActionListener((ActionListener)btnevent);
		dangnhap.dangnhap.addActionListener((ActionListener)btnevent);
		dangnhap.huy.addActionListener((ActionListener)btnevent);
		hanghoa.tolbar.newbtn.addActionListener((ActionListener)btnevent);
		hanghoa.tolbar.closebtn.addActionListener((ActionListener)btnevent);
		hanghoa.tolbar.openbtn.addActionListener((ActionListener)btnevent);
		hanghoa.newhanghoa.dongy.addActionListener((ActionListener)btnevent);
		hanghoa.suahanghoa.dongy.addActionListener((ActionListener)btnevent);
		hanghoa.newhanghoa.huy.addActionListener((ActionListener)btnevent);
	}
}
